﻿<%@ Application Language="C#" %>
<%@ Import Namespace="System.Reflection" %>
<%@ Import Namespace="log4net" %>
<%@ Import Namespace="System.IO" %>

<script runat="server">

    void Application_Start(object sender, EventArgs e) 
    {
        log4net.Config.XmlConfigurator.ConfigureAndWatch(new System.IO.FileInfo(Server.MapPath("~") + @"\Configs\log4net.xml"));
        File.AppendAllText(Server.MapPath(@"~\Log\Application.log"),
                           string.Format("{0} 应用程序启动！\r\n", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")));

    }
    
    void Application_End(object sender, EventArgs e) 
    {
        //  Code that runs on application shutdown

    }
        
    void Application_Error(object sender, EventArgs e) 
    { 
        ILog log =
            LogManager.GetLogger("GONES.Error");

        string url = Request.RawUrl;
        Exception ex = Server.GetLastError();

        log.Error(string.Format("\r\nUrl:{0}\r\nError:{1}", url, ex.ToString()));
        //Response.Clear();
        //Response.Write("程序出错，请与管理员联系!");
        //Response.End();
    }

    void Session_Start(object sender, EventArgs e) 
    {
        // Code that runs when a new session is started

    }

    void Session_End(object sender, EventArgs e) 
    {
        // Code that runs when a session ends. 
        // Note: The Session_End event is raised only when the sessionstate mode
        // is set to InProc in the Web.config file. If session mode is set to StateServer 
        // or SQLServer, the event is not raised.

    }
       
</script>
